﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace T7task1
{
    public partial class Form1 : Form
    {
        DataTable dt = new DataTable();
        int index = 0;
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            string sql = "select * from Li";
            dt = DBHelper.SelectByAdapter(sql);
            ShowInfo(0);
        }
        public void ShowInfo(int i)
        {
            textBox1.Text = dt.Rows[i]["GameName"].ToString();
            textBox2.Text = dt.Rows[i]["Customer"].ToString();
            textBox3.Text = dt.Rows[i]["Anarchy"].ToString();
            textBox4.Text = dt.Rows[i]["Style"].ToString();

        }

        private void button1_Click(object sender, EventArgs e)
        {
            if (index == 0)
            {
                button1.Enabled = false;
                button2.Enabled = true;
            }
            else
            {
                button1.Enabled = true;
                button2.Enabled = true;
                index--;
                ShowInfo(index);
            }
        }

        private void button2_Click(object sender, EventArgs e)
        {
            if (index == dt.Rows.Count - 1)
            {
                button1.Enabled = true;
                button2.Enabled = false;
            }
            else
            {
                button1.Enabled = true;
                button2.Enabled = true;
                index++;
                ShowInfo(index);
            }
        }
    }
}
